import Vue from 'vue'
import Router from 'vue-router'
import store from './store.js'

Vue.use(Router)

const router = new Router({
	mode: 'history',
	base: process.env.BASE_URL,
	routes: [
		// 登录
		{
			path: '/Login',
			name: 'Login',
			component: () => import('./views/Login.vue')
		},
		
	]
})

// 全局路由守卫
router.beforeEach((to, from, next) => {
	if (to.path == "/Login") {
		return next();
	}
	if (store.state.token) {
		return next()
	} else {
		return next('/Login')
	}
})

export default router
